<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:f="livcos.org/ns/xslt/function"
	exclude-result-prefixes="f">

	<xsl:param name="viewObjId"/>
	<xsl:param name="basePath"/>
	<xsl:param name="dataPath"/>
	
	<xsl:template match="uri" mode="#all">
		<access>
			<xsl:attribute name="obj">
				<xsl:choose>
					<xsl:when test="normalize-space(@path) = ''">../<xsl:value-of select="@name"/></xsl:when>
					<xsl:when test="starts-with(@path, '/')"><xsl:value-of select="@path"/>/<xsl:value-of select="@name"/></xsl:when>
					<xsl:otherwise>../<xsl:value-of select="@path"/>/<xsl:value-of select="@name"/></xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:if test="normalize-space(@ext) != ''">
				<xsl:attribute name="scope">
					<xsl:choose>
						<xsl:when test="@ext = 'view'">view</xsl:when>
						<xsl:when test="@ext = 'job'">view</xsl:when>
						<xsl:when test="@ext = 'cosmos'">cosmos</xsl:when>
						<xsl:when test="@ext = 'content'">content</xsl:when>
						<xsl:when test="@ext = 'plain'">content</xsl:when>
						<xsl:when test="@ext = 'meta'">meta</xsl:when>
						<xsl:when test="@ext = 'cache'">cache</xsl:when>
						<xsl:when test="@ext = 'history'">history</xsl:when>
						<xsl:when test="@ext = 'data'">data</xsl:when>
						<xsl:when test="@ext = 'xsl'">content</xsl:when>
						<xsl:when test="@ext = 'xslt'">content</xsl:when>
						<xsl:otherwise>view</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
			</xsl:if>
			<xsl:copy-of select="param"/>
		</access>
	</xsl:template>

	<xsl:template match="uri[@full = '/favicon.ico']">
		<access obj="/livcos.org/web/img/icon" scope="content"/>
	</xsl:template>

	<xsl:template match="uri[(@full = '/robots.txt')]">
		<access obj="/livcos.org/web/robots" scope="view"/>
	</xsl:template>

	<xsl:template match="uri[(@full = '/') or (@full = '/index.html')]">
		<access obj="/livcos.org/web/redirect" scope="view"/>
	</xsl:template>

</xsl:stylesheet>
